<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>removeElement</title>
</head>

<body>
    <div id="needRemoveElement">需要移除的div元素</div>
    <button id="removeBtn" type="button">点击我移除div元素</button>
    <script>
        const removeElement = el => el.parentNode.removeChild(el);
        const btn = document.querySelector('#removeBtn');
        const div = document.querySelector('#needRemoveElement');
        btn.addEventListener('click', () => removeElement(div));
    </script>
</body>

</html>